<?php

namespace App\Http\Requests\Api;

use Illuminate\Foundation\Http\FormRequest;

class UserInputDTO extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    public function rules()
    {
        return [
            'is_promoter' => 'boolean',
            'recommend_id' => 'integer',
            'name' => 'required|max:20',
            'mobile' => 'required|regex:/^04[0-9]{8}$/',
            'driver_license' => 'required|max:40',
            'email' => 'email',
            'passport' => 'max:40',
            'bank_bsb' => 'digits:6',
            'bank_no' => 'max:40',
            'bank_mark' => 'max:200',
            'address' => 'max:200',
            //'avatar' => 'required|url',
            //'picture_license' => 'required|url',
            //'picture_passport' => 'required|url',
            'mark' => 'max:200',
        ];
    }

    public function messages()
    {
        return [
            'is_promoter.boolean' => '请确认是否为推广人',
            'recommend_id.integer' => '推荐人不合法',
            'name.required' => '请填写客户姓名',
            'name.max' => '姓名不合法',
            'mobile.required' => '请填写客户电话',
            'mobile.regex' => '电话不合法',
            'driver_license.required' => '请填写客户驾驶证号码',
            'driver_license.max' => '驾驶证不合法',
            //'email.required' => '请填写客户邮箱',
            'email.email' => '邮箱不合法',
            //'passport.required' => '请填写客户护照号码',
            'passport.max' => '护照不合法',
            //'bank_bsb.required' => '请填写银行卡BSB',
            'bank_bsb.digits' => 'BSB必须是六位数字',
            //'bank_no.required' => '请填写银行卡号码',
            'bank_no.max' => '银行卡号码不合法',
            //'bank_mark.required' => '请填写银行卡信息',
            'bank_mark.max' => '银行卡信息不合法',
            'address.required' => '请填写客户联系地址',
            'address.max' => '联系地址不合法',
            'avatar.required' => '请上传客户照片',
            'avatar.url' => '客户照片不合法',
            'picture_license.required' => '请上传客户驾驶证',
            'picture_license.url' => '驾驶证不合法',
            'picture_passport.required' => '请上传客户护照',
            'picture_passport.url' => '护照照片不合法',
            'mark.required' => '请填写客户备注',
            'mark.max' => '备注不合法',
        ];
    }
}
